﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace GymMaster.View.Cadastro
{
    public partial class CadastroExercicio : BasePageGymMaster
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ddlTipoExercicio.Items.Insert(0, new ListItem("<< Selecione >>", "0"));
        }

        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                GymMasterEntities entity = new GymMasterEntities();
                EXERCICIO exercicio = new EXERCICIO();
                exercicio.DESCRICAO = txtExercicio.Text;
                exercicio.ID_TIPO_EXERCICIO = ddlTipoExercicio.SelectedIndex;

                entity.AddToEXERCICIO(exercicio);
                entity.SaveChanges();

                ShowMsg("Cadastro realizado com sucesso");
                txtExercicio.Text = "";
            }
            catch (Exception ex)
            {
                ShowMsg("Ocorreu um problema ao cadastrar.");
            }
        }


    }
}